//
//  MYMyAccountsSafetyVC.swift
//  MuYing
//
//  Created by tbb on 2019/8/8.
//  Copyright © 2019 TBB. All rights reserved.
//

import UIKit

class MYMyAccountsSafetyVC: YQMYBaseTableViewController {

    @objc var model = YQPInfoModel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.isNavShadow = true;
        self.navigationItem.title = kYQLSSwift("账号安全");
    }
    
    override func setupView() {
        super.setupView();
        self.listTableView.backgroundColor = UIColorFromHex(rgbValue: 0xFAFAFA);
        self.listTableView.register(UINib.init(nibName: "MYMySetTextCell", bundle: nil), forCellReuseIdentifier: "MYMySetTextCell");
    }
    
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 2;
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 0 {
            return 2;
        }
        return 1;
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: "MYMySetTextCell") as? MYMySetTextCell else { return UITableViewCell() };
        if indexPath.section == 0 {
            if indexPath.row == 0 {
                cell.titleLb.text = kYQLSSwift("绑定手机");
                if self.model.isBandPhone == "1" {
                    cell.subLb.text = kYQLSSwift("已绑定")
                }else{
                    cell.subLb.text = kYQLSSwift("未绑定")
                }
            }else{
                if self.model.isBandEmail == "1" {
                    cell.subLb.text = kYQLSSwift("已绑定")
                }else{
                    cell.subLb.text = kYQLSSwift("未绑定")
                }
                cell.titleLb.text = kYQLSSwift("绑定邮箱");
            }
        }else{
            cell.subLb.text = ""
            cell.titleLb.text = kYQLSSwift("修改密码");
        }
        return cell;
    }
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 58;
    }
    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 10.0;
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if  indexPath.section == 1 {
            let VC = MYMySetRevampVC();
            [self.navigationController?.pushViewController(VC, animated: true)];
        }else{
            let bindingVC = MYMySetBindingAccountsVC();
            bindingVC.type = indexPath.row;
            [self.navigationController?.pushViewController(bindingVC, animated: true)];
        }
    }
    
    
    @objc func setModel(model:YQPInfoModel)
    {
        self.model = model
        self.listTableView .reloadData()
    }
}
